<?xml version='1.0' encoding='UTF-8' ?>
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
	xmlns:tags="http://tags.com/facelets">
	
	<h:form id="listForm" pt:role="form" prependId="true">
	
		
		<h:panelGroup layout="block" styleClass="panel panel-default" style="height: 100%">
		
			<h:panelGroup layout="block" styleClass="panel-heading" style="min-height:26 px !important;">
			
				<h:panelGroup layout="block" styleClass="row clearfix">
					<h:panelGroup layout="block" styleClass="col-xs-12">
						<h:panelGroup layout="block" style="width:24px !important; float:left;">
							<h:graphicImage value="#{(empty titleImage)?'/resources/img/window.png': titleImage}" style="border: none;" />
						</h:panelGroup>						
						<h:panelGroup layout="block" style="float:left; padding:3px;">
							<h4 class="panel-title">#{msg[title]}</h4>
						</h:panelGroup>
					</h:panelGroup>
					
				</h:panelGroup>
			</h:panelGroup>
			
			<h:panelGroup layout="block" styleClass="panel-body">
				
	    		<ui:insert name="content" >	
	    			<ui:insert name="filters" />
	    			    							
					<tags:dataTable id="dataTable" mb="#{mb}" updateOnChange="buttonBar">  
	    				<ui:insert name="columns" />		    
		  			</tags:dataTable>
		  		</ui:insert>
				
			</h:panelGroup>
	
			<h:panelGroup id="buttonBar" layout="block" styleClass="panel-footer modal-footer">
			
	    		<ui:insert name="buttons" >	
	    			
	    			<tags:button 
	    				id="btnNew"
	    				value="fw.btn.new"
		    			tooltip="fw.btn.new.tooltip"
		    			mb="#{mb}" action="create" 
		    			update=":formEdit"
		    			styleClass="btn-success"
		    			onevent="openModalOnComplete" />	
	    		
	    			<tags:button 
	    				id="btnEdit"
	    				value="fw.btn.edit"
		    			tooltip="fw.btn.edit.tooltip"
		    			mb="#{mb}" action="edit" 
		    			disabled="#{empty mb.selectedID or mb.selectedID lt 0}"
		    			process="@form"	update=":formEdit" 
		    			styleClass="btn-primary btn-edit"
		    			onevent="openModalOnComplete" />	
					
					<tags:confirmButton 
						id="btnConfirm"
						value="fw.btn.delete"
						tooltip="fw.btn.delete.tooltip"
		    			process="@none"	update="@none"		    			
		    			styleClass="btn-danger"
		    			mb="#{mb}" actionYes="delete" 
		    			updateYes=":listForm:divTable"
		    			oneventYes="onCompletConfirm"
		    			disabled="#{empty mb.selectedID or mb.selectedID lt 0}"
		    			title="fw.title.delete"
		    			message="fw.msg.delete"
		    		/>		
								
				</ui:insert>
			</h:panelGroup>
		</h:panelGroup>
			
	</h:form>
	   
		<script>
			
			function openModalOnComplete(data){
				if (data.status == "success"){
					openModal('myModal');
				}
			}
			
		</script>
    <ui:insert name="modals" />	
			   
</ui:composition>